#pragma once
#include "hash.h"
namespace cc
{
	template<class K,class V>
	struct KofT
	{
		const K& operator()(const pair<K, V>& x)
		{
			return x.first;
		}
	};
	template<class K,class V>
	class map
	{
	public:
		typedef typename cc::Iterator<K, pair<K, V>, pair<K, V>&, pair<K, V>*, KofT<K,V>, HashFunc<K>> iterator;
		pair<iterator,bool> insert(const pair<K, V>& x)
		{
			return Table.insert(x);
		}
		iterator begin()
		{
			return Table.begin();
		}
		iterator end()
		{
			return Table.end();
		}
		V& operator[](const K& x)
		{
			pair<iterator, bool>ret = Table.insert(make_pair(x, V()));
			return ret.first->second;
		}
		iterator find(const K& x)
		{
			return Table.find(x);
		}
	private:
		cc::HashTable<K, pair<K, V>, KofT<K,V>, HashFunc<K>> Table;
	};
}
